#ifndef CONFIG_H
#define CONFIG_H

#include <vector>
#include <string>
#include <sstream>
#include <boost/property_tree/ptree.hpp>

struct ConfigMaster
{
    ConfigMaster();
    
    std::string mHost;
    int mPort;
};

struct ConfigSlot
{
    ConfigSlot();
    
    std::string mHost;
    int mPort;
    
    int mWorkers;
};

class Config
{
 public:
    /** load data from JSON file to Config */
    void loadFromFile(const char *fileName, std::string &error);
    
    /** load data from string to Config */
    void loadFromString(const char *Data, std::string &error);

    
    /** get setting of Master */
    inline ConfigMaster getConfigMaster() 
    { 
        return mConfigMaster;
    }

    /** get setting of Slot */
    bool getConfigSlot(unsigned int index, ConfigSlot &configSlot);
    
    inline int getSlots()
    {
        return mConfigSlots.size();
    }

    
    /** copy data configuration to Stream */
    void toStream(std::stringstream &output, std::string &error);

    
 private:
    ConfigMaster mConfigMaster;
    std::vector<ConfigSlot> mConfigSlots;
    boost::property_tree::ptree mSourceData;
    
    void update(std::string &error);
    
};

#endif